import axios from "axios";
import qs from 'qs'; // 使用 qs 库格式化参数

// 获取收藏夹商品
export const fetchFavGoods = async (customerId) => {
  const response = await axios.get("http://localhost:8080/userIntend/likes", {
    params: { customerId },
  });
  return response.data; // 返回购物车商品列表
};

// 获取商品详情
export const fetchGoodDetails = async (goodId) => {
  const response = await axios.get(`http://localhost:8080/good/info/${goodId}`);
  return response.data; // 返回商品详情
};

// 从收藏夹中删除商品
export const removeFromFav = async (goodIds, customerId) => {
  console.log("request", goodIds, customerId);
  const response = await axios.put("http://localhost:8080/userIntend/like/remove", null, {
    params: {
      goodIds,
      customerId,
    },
    paramsSerializer: (params) => qs.stringify(params, { indices: false }),
  });
  return response.data;
};

